home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 121
/
FreelogMagazineJuilletAout2014-No121.iso
/
Outils
/
Adobe-Air
/
adobe-air_13.exe
/
[0]
/
setup.swf
/
scripts
/
mx
/
controls
/
Text.as
< prev
next >
Wrap
Text File
|
2014-03-27
|
5KB
|
165 lines
package mx.controls
{
import mx.core.UITextField;
import mx.core.mx_internal;
import mx.events.FlexEvent;
use namespace mx_internal;
public class Text extends Label
{
mx_internal static const VERSION:String = "3.0.0.0";
private var widthChanged:Boolean = true;
private var lastUnscaledWidth:Number = NaN;
public function Text()
{
super();
selectable = true;
truncateToFit = false;
addEventListener(FlexEvent.UPDATE_COMPLETE,updateCompleteHandler);
}
private function measureUsingWidth(param1:Number) : void
{
var _loc2_:Number = NaN;
var _loc3_:Number = NaN;
var _loc5_:Number = NaN;
var _loc6_:Boolean = false;
_loc2_ = getStyle("paddingLeft");
_loc3_ = getStyle("paddingTop");
var _loc4_:Number = getStyle("paddingRight");
_loc5_ = getStyle("paddingBottom");
textField.validateNow();
textField.autoSize = "left";
if(!isNaN(param1))
{
textField.width = param1 - _loc2_ - _loc4_;
measuredWidth = Math.ceil(textField.textWidth) + UITextField.TEXT_WIDTH_PADDING;
measuredHeight = Math.ceil(textField.textHeight) + UITextField.TEXT_HEIGHT_PADDING;
}
else
{
_loc6_ = textField.wordWrap;
textField.wordWrap = false;
measuredWidth = Math.ceil(textField.textWidth) + UITextField.TEXT_WIDTH_PADDING;
measuredHeight = Math.ceil(textField.textHeight) + UITextField.TEXT_HEIGHT_PADDING;
textField.wordWrap = _loc6_;
}
textField.autoSize = "none";
measuredWidth += _loc2_ + _loc4_;
measuredHeight += _loc3_ + _loc5_;
if(isNaN(explicitWidth))
{
measuredMinWidth = DEFAULT_MEASURED_MIN_WIDTH;
measuredMinHeight = DEFAULT_MEASURED_MIN_HEIGHT;
}
else
{
measuredMinWidth = measuredWidth;
measuredMinHeight = measuredHeight;
}
}
override public function set percentWidth(param1:Number) : void
{
if(param1 != percentWidth)
{
widthChanged = true;
invalidateProperties();
invalidateSize();
}
super.percentWidth = param1;
}
override public function set explicitWidth(param1:Number) : void
{
if(param1 != explicitWidth)
{
widthChanged = true;
invalidateProperties();
invalidateSize();
}
super.explicitWidth = param1;
}
private function updateCompleteHandler(param1:FlexEvent) : void
{
lastUnscaledWidth = NaN;
}
override protected function childrenCreated() : void
{
super.childrenCreated();
textField.wordWrap = true;
textField.multiline = true;
textField.mouseWheelEnabled = false;
}
override protected function commitProperties() : void
{
super.commitProperties();
if(widthChanged)
{
textField.wordWrap = !isNaN(percentWidth) || !isNaN(explicitWidth);
widthChanged = false;
}
}
override protected function updateDisplayList(param1:Number, param2:Number) : void
{
var _loc7_:Boolean = false;
if(isSpecialCase())
{
_loc7_ = isNaN(lastUnscaledWidth) || lastUnscaledWidth != param1;
lastUnscaledWidth = param1;
if(_loc7_)
{
invalidateSize();
return;
}
}
var _loc3_:Number = getStyle("paddingLeft");
var _loc4_:Number = getStyle("paddingTop");
var _loc5_:Number = getStyle("paddingRight");
var _loc6_:Number = getStyle("paddingBottom");
textField.setActualSize(param1 - _loc3_ - _loc5_,param2 - _loc4_ - _loc6_);
textField.x = _loc3_;
textField.y = _loc4_;
if(Math.floor(width) < Math.floor(measuredWidth))
{
textField.wordWrap = true;
}
}
override protected function measure() : void
{
if(isSpecialCase())
{
if(!isNaN(lastUnscaledWidth))
{
measureUsingWidth(lastUnscaledWidth);
}
else
{
measuredWidth = 0;
measuredHeight = 0;
}
return;
}
measureUsingWidth(explicitWidth);
}
private function isSpecialCase() : Boolean
{
var _loc1_:Number = getStyle("left");
var _loc2_:Number = getStyle("right");
return (!isNaN(percentWidth) || !isNaN(_loc1_) && !isNaN(_loc2_)) && isNaN(explicitHeight) && isNaN(percentHeight);
}
}
}